package com.hghivln.erpwarehouse.system.mapper;

import com.hghivln.erpwarehouse.system.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hghivln
 * @since 2021-07-01
 */
@Repository
public interface RoleMapper extends BaseMapper<Role> {

    @Select("select mid from sys_role_menu where rid = #{rid}")
    List<Integer> queryMenuIdsByRid(@Param("rid") Integer rid);

    @Insert("insert into sys_role_menu(rid,mid) values(#{rid},#{mid})")
    void saveRoleMenu(@Param("rid") Integer rid,@Param("mid") Integer mid);

    @Delete("delete from sys_role_menu where rid = #{rid}")
    void deletRoleMenuById(Integer rid);

    List<Integer> queryMenuIdsByRids(@Param("roleIds") List<Integer> rids);

    @Delete("delete from sys_user_role where rid = #{id}")
    void removeUserRoleByRid(Serializable id);
}
